
public class Bank extends myException{
    private String id;
    private String name;
    private double balance;

    public Bank() {
    }

    public Bank(String id, String name, double balance) {
        this.id = id;
        this.name = name;
        this.balance = balance;
    }
public void deposit(double m) throws myException {
        try {

            if (m < 0) {

                throw new myException("存款金额不能为负数");
            }
            balance+=m;
        }catch (Exception e)
        {
            System.out.println(e.getMessage());
        }

}
public void withdraw(double m) throws myException {
        try{
        if(m<0||balance<0){
            throw new myException("取款金额不能为负数");
        }
       if(m>balance)     {
           throw new myException("余额不足");
       }
            balance-=m;
        }
        catch (Exception e)
        {
            System.out.println(e.getMessage());
        }

}
public void viewBalance() {
    System.out.println("账户余额为："+balance);
}
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    @Override
    public String toString() {
        return "Bank{id = " + id + ", name = " + name + ", balance = " + balance + "}";
    }
}
